<template>
  <div class="section">
    <div class="wrapper">
      <div class="title">
        <span>{{ wapperTitle }}</span>
      </div>
      <div class="recommend">
        <el-card :body-style="{ padding: '0px' }" v-for="(item, index) in cardContext" :key="index">
          <div class="card-image">
            <img v-lazy="resUrl + item.imgUrl" class="image" />
          </div>
          <div class="card-title">
            <div class="info">
              <p>
                {{ item.content }}
              </p>
            </div>
            <div class="bottom">
              <span class="bot-left">
                {{ item.author }}
              </span>
              <span class="bot-right">
                <em 
                  :class="{'em-cur': item.compony == 1}"
                  :style="{'color': item.compony == 1 ? 'red' : '#636363'}">
                  {{ item.wapper_data }}
                </em>
                {{item.compony === "1" ? "元起" : item.compony === "2" ? "点赞" : "人浏览过"}}
              </span>
            </div>
          </div>
        </el-card>
      </div>
    </div>
  </div>
</template>

<script>
import base from "@/api/base.js";

export default {
  props: {
    wapperTitle: String,
    cardContext: Array
  },
  data(){
    return {
      resUrl: base.host
    }
  },
  mounted(){
    console.log(this.resUrl);
  }
}
</script>

<style lang="less" scoped>
.em-cur{
  color: red;
  font-size: 20px !important;
  font-weight: 500 !important;
}
.section {
  padding-top: 20px;
  padding-bottom: 20px;

  .wrapper {
    width: 1200px;
    margin: 0 auto;

    .title {
      height: 70px;
      color: #3c3c3c;
      text-align: center;
      font-size: 30px;
      font-weight: 500;
      line-height: 70px;
    }

    .recommend {
      display: flex;
      flex-wrap: wrap;
    }
  }
}

.el-card {
  width: 275px;
  height: 300px;
  border: none;
  border-radius: 0%;
  margin-left: 20px;
  margin-top: 10px;
  margin-bottom: 10px;

  .card-image {
    overflow: hidden;
    height: 185px;
  }

  .image {
    transition: all 1.2s;
  }

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  img:hover {
    transform: scale(1.1);
  }

  .card-title {
    padding: 0 15px;
    overflow: hidden;

    .info {
      height: 50px;
      font-size: 16px;
      font-weight: 600;
      margin-top: 15px;

      p {
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
    }

    .bottom {
      margin-top: 15px;
      font-size: 14px;

      .bot-left {
        max-width: 65%;
        min-width: 55%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        float: left;
        font-weight: 600;
        color: #3c3c3c;
        color: #636363;
      }

      .bot-right {
        float: right;
        margin-right: 0;
        line-height: 20px;
        em {
          color: red;
          font-style: normal;
          font-weight: 600;
          font-size: 15px;
        }
      }
    }
  }
}
</style>